package com.gy.componit;

import com.gy.game.Game;
import lombok.Data;

import java.awt.*;
import java.math.BigDecimal;

/**
 * 普通子弹特效类
 * @author Dsy
 * @create 2022-02-05  20:27
 */
@Data
public class SimpleBulletSpecialEffect implements Component{

    private Color color;
    private BigDecimal x,y;
    private double size;

    private int maxLife = 200;
    private int life = maxLife;

    @Override
    public void paint(Graphics g) {
        int transparency = color.getAlpha();
        g.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), transparency * life / maxLife));
//        g.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 255));
//        int curSize = (int)size * life / maxLife;
        int curSize = (int)size;
        g.fillOval((int)(x.doubleValue()-curSize), (int)(y.doubleValue()-curSize), (int)curSize*2, (int)curSize*2);
    }

    @Override
    public AreaPoint getAreaPoint(int areaSize) {
        return null;
    }

    @Override
    public void move(Game game) {
        life -= 1;
    }

    @Override
    public int getOrder() {
        return 0;
    }
}
